package nl.hva.three2learn.model;

import java.io.Serializable;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Table(name = "post")
@Entity
public final class Post implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4764749032388729860L;

	@Id
	@GeneratedValue
	@Column(name = "post_id")
	private long id;
	
	@Column(name = "text")
	private String text;
	
	@Column(name = "creation_date")
	private Date creationDate;
	
	@ManyToOne
	private User owner;
	
	@ManyToOne
	private Topic topic;

	public Post(String text, User owner, Topic topic) {
		this.text = text;
		this.owner = owner;
		this.topic = topic;
		
		this.creationDate = new GregorianCalendar().getTime();
	}
	
	public Post() { }

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

	public Topic getTopic() {
		return topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}
}
